package org.cainiao.algorithm.temp.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
public class HJ17 {

    private static final Pattern pattern = Pattern.compile("^([WSAD])(\\d{1,2})$");

    public static void main(String[] args) throws IOException {
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
            String input;
            while ((input = bufferedReader.readLine()) != null) {
                int x = 0;
                int y = 0;
                for (String movement : input.split(";")) {
                    Matcher matcher = pattern.matcher(movement);
                    if (matcher.matches()) {
                        int steps = Integer.parseInt(matcher.group(2));
                        switch (matcher.group(1)) {
                            case "A":
                                x -= steps;
                                break;
                            case "D":
                                x += steps;
                                break;
                            case "W":
                                y += steps;
                                break;
                            case "S":
                                y -= steps;
                                break;
                        }
                    }
                }
                System.out.printf("%d,%d%n", x, y);
            }
        }
    }

    private static void temp() {
        Scanner in = new Scanner(System.in);
        System.out.println(">> 1");
        while (in.hasNextInt()) {
            System.out.println(">> 2");
            int a = in.nextInt();
            System.out.println(">> 3");
            int b = in.nextInt();
            System.out.println(a + b);
        }
    }
}
